package com.example.algorithm.utils;


import com.example.algorithm.pojo.Department;
import lombok.Data;


import java.util.HashSet;
@Data
public class AreaJudgeUtils {

    public static HashSet citySet = new HashSet();

    static {
        citySet.add("杭州市");
        citySet.add("宁波市");
        citySet.add("温州市");
        citySet.add("绍兴市");
        citySet.add("湖州市");
        citySet.add("嘉兴市");
        citySet.add("金华市");
        citySet.add("衢州市");
        citySet.add("台州市");
        citySet.add("舟山市");
        citySet.add("丽水市");
    }


    public static Department getDepartMent(String depName) {
        Department department = new Department();
        department.setDepName(depName);
        department.setWeight(0);

        if (depName != null && !"".equals(depName)) {
            if (depName.length() < 3) {
                return department;
            }
            String substring = depName.substring(0, 3);

            if (citySet.contains(substring)) {
                department.setDepName(substring);
                department.setWeight(3);
                department.setLevel("市级");
            }
            if (depName.contains("国家") || depName.contains("中央") || depName.contains("国务院") || depName.contains("部") || depName.contains("国办专办")) {
                department.setDepName(depName);
                department.setLevel("国家级");
                department.setWeight(6);
            }
            if (depName.contains("浙江") || depName.contains("省") || depName.contains("厅")) {
                if (depName.contains("省委办公厅") || depName.contains("省政府办公厅")) {
                    department.setDepName(depName);
                    department.setLevel("省级");
                    department.setWeight(5);
                } else {
                    department.setLevel("省级");
                    department.setDepName(depName);
                    department.setWeight(4);
                }
            }

        }

        return department;
    }

    /**
     * 带有区县使用的  -- 没有定版本
     * @param depName
     * @return
     */
//    public static Department getDepartMent(String depName) {
//        Department department = new Department();
//        department.setDepName(depName);
//        department.setWeight(0);
//        if (depName != null && !"".equals(depName)) {
//            if (depName.length() < 3) {
//                return department;
//            }
//            String substring = depName.substring(0, 3);
//
//            String areaDept = depName.substring(3);
//
//            /**
//             * 区县级判断  长度大于3 截取掉前3位  包含市、区、县？
//             */
//            if(areaDept.contains("市") || areaDept.contains("区") || areaDept.contains("县")) {
//                department.setDepName(depName);
//                department.setWeight(2);
//                department.setLevel("区县级");
//            }
//            else if (citySet.contains(substring)) {
//                department.setDepName(substring);
//                department.setWeight(3);
//                department.setLevel("市级");
//            }
//            else if (depName.contains("浙江") || depName.contains("省") || depName.contains("厅")) {
//                if (depName.contains("省委办公厅") || depName.contains("省政府办公厅")) {
//                    department.setDepName(depName);
//                    department.setLevel("省级");
//                    department.setWeight(5);
//                } else {
//                    department.setLevel("省级");
//                    department.setDepName(depName);
//                    department.setWeight(4);
//                }
//            }
//            else if (depName.contains("国家") || depName.contains("中央") || depName.contains("国务院") || depName.contains("部") || depName.contains("国办专办")) {
//                department.setDepName(depName);
//                department.setLevel("国家级");
//                department.setWeight(6);
//            }
//        }
//        return department;
//    }
}
